package com.example.aopdemo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDKInvocatonHandler implements InvocationHandler {

    private Object target;

    public JDKInvocatonHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("我是中介,开始代理");
        Object result = method.invoke(target,args);
        System.out.println("我是中介,结束代理");
        return result;
    }
}
